﻿using UnityEngine;
using YooAsset;

public class ProjectConfig
{
    private static ProjectEnvironment env;
    public static Environment Env
    {
        get
        {
            if (env == null)
                env = Resources.Load<ProjectEnvironment>("ProjectEnvironment");
            return env.env;
        }
    }

    private static ConfigItem config;
    public static ConfigItem Config
    {
        get
        {
            if (config == null)
                config = new ConfigItem();
            switch (Env)
            {
                case Environment.Editor:
                    config.playMode = EPlayMode.EditorSimulateMode;
                    config.useBytes = false;
                    break;
                case Environment.Editor_Art:
                    config.playMode = EPlayMode.EditorSimulateMode;
                    config.useBytes = true;
                    break;
                case Environment.Android_Dev:
                    config.playMode = EPlayMode.HostPlayMode;
                    config.useBytes = true;
                    break;
                case Environment.Android_Release:
                    config.playMode = EPlayMode.HostPlayMode;
                    config.autoProfile = false;
                    config.profilingFuncs = false;
                    config.profilingMemory = false;
                    config.useBytes = true;
                    break;
                case Environment.Ios_Dev:
                    config.playMode = EPlayMode.HostPlayMode;
                    config.useBytes = true;
                    break;
                case Environment.Ios_Release:
                    config.playMode = EPlayMode.HostPlayMode;
                    config.autoProfile = false;
                    config.profilingFuncs = false;
                    config.profilingMemory = false;
                    config.useBytes = true;
                    break;
                case Environment.WxMiniGame_Dev:
                    config.playMode = EPlayMode.WebPlayMode;
                    config.development = true;
                    config.autoProfile = true;
                    config.profilingFuncs = true;
                    config.profilingMemory = true;
                    config.useBytes = true;
                    break;
                case Environment.WxMiniGame_Release:
                    config.playMode = EPlayMode.WebPlayMode;
                    config.development = false;
                    config.autoProfile = false;
                    config.profilingFuncs = false;
                    config.profilingMemory = false;
                    config.useBytes = true;
                    break;
            }
            return config;
        }
    }

    public static bool IsWxMiniGame
    {
        get
        {
            return Env == Environment.WxMiniGame_Dev
                || Env == Environment.WxMiniGame_Release;
        }
    }
}

public class ConfigItem
{
    public string appVersion = "v0.0.1";
    public int appCode = 1;
    public string projectName = "测试项目";
    public string cdn = "http://192.168.15.111:9527";
    public bool development = true;
    public bool autoProfile = true;
    public int targetFrameRate = 60;
    public Vector2 resolution = new Vector2(720, 1280);
    public bool openGM = true;
    public bool openLog = true;

    #region Android
    public bool useCustomKeystore = false;
    public string keystoreName = "";
    public string keystorePass = "";
    public string keyaliasName = "";
    public string keyaliasPass = "";
    public int versionCode = 1;
    #endregion

    #region HybridCLR
    public bool useBytes = false;
    public string[] aotDllList = new string[]
    {
        "DOTween.dll",
        "Lit.dll",
        "Newtonsoft.Json.dll",
        "System.Core.dll",
        "UniTask.dll",
        "UnityEngine.CoreModule.dll",
        "UnityEngine.UI.dll",
        "mscorlib.dll",
    };
    #endregion

    #region YooAsset
    public EPlayMode playMode = EPlayMode.EditorSimulateMode;
    public string packageName = "main";
    #endregion

    #region WxMiniGame
    public string appId = "wx757cb1d3bb936ed0";

    public string bundlePathIdentifier = "main;";
    public string bundleExcludeExtensions = "json;version;";
    public string preloadFiles = "PackageManifest_main";

    public bool profilingFuncs = false;
    public bool profilingMemory = false;

    public bool useFriendRelation = true;
    #endregion
}

